<!DOCTYPE html>
<html>
	<head>
	<meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title></title>
    <script src="js/mui.min.js"></script>
    <link href="css/mui.min.css" rel="stylesheet"/>
    <link href="css/mui.picker.min.css" rel="stylesheet" />
    <link href="style/fjol_style.css" rel="stylesheet" />
    <link rel="stylesheet" type="text/css" href="style/xol_style.css"/>
    <script type="text/javascript" charset="utf-8">
      	mui.init();
    	
   		
    </script>
	</head>
	<body>
		<header class="mui-bar mui-bar-nav newbgRed">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		    <h1 class="mui-title">添加订阅</h1>
		</header>
		<div class="mui-content">
		    <ul class="mui-table-view">
		            <!--<li class="mui-table-view-cell" id="openCityList">
		                <a class="mui-navigate-right">
		                    城市
		                    <span id="cityArea" class="mui-pull-right mr10">泉州市</span>
		                </a>
		            </li>-->
		            <li class="mui-table-view-cell" id="citySite">
		                <a class="mui-navigate-right">
		                     区域
		                    <span class="mui-pull-right mr10 " id="citySiteResult">不限</span>
		                </a>
		            </li>
		            <li class="mui-table-view-cell" id="inHouseType">
		                <a class="mui-navigate-right">
		                    房型
		                    <span class="mui-pull-right mr10" id="showInHouseType">不限</span>
		                </a>
		            </li>
		            <li class="mui-table-view-cell" id="houseType">
		                <a class="mui-navigate-right">
		                     类型
		                    <span class="mui-pull-right mr10" id="showHouseType">不限</span>
		                </a>
		            </li>
		            <li class="mui-table-view-cell" id="decorateType">
		                <a class="mui-navigate-right">
		                     装修
		                    <span class="mui-pull-right mr10" id="showDecorateType">不限</span>
		                </a>
		            </li>
		            <li class="mui-table-view-cell">
		                <a class="">
		                     面积
		                    <div class="" align="center">
		                    	<div class="mui-numbox" data-numbox-step='1' data-numbox-min='0' data-numbox-max='999'>
		                    	    <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
		                    	    <input class="mui-input-numbox" type="number" id="aSquare" />
		                    	    <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
		                    	</div>
		                    	—
		                    	<div class="mui-numbox" data-numbox-step='1' data-numbox-min='0' data-numbox-max='999'>
		                    	    <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
		                    	    <input class="mui-input-numbox" type="number" id="bSquare" />
		                    	    <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
		                    	</div>

		                    	m	&sup2;
		                    </div>
		                </a>
		            </li>
		            <li class="mui-table-view-cell">
		                <a class="">
		                     售价
		                    <div class="" align="center">
		                    	<!--<em id="housePrice">不限</em>-->
		                    	<div class="mui-numbox" data-numbox-step='1' data-numbox-min='0' data-numbox-max='999'>
		                    	    <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
		                    	    <input class="mui-input-numbox" type="number" id="aTotalPrice" />
		                    	    <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
		                    	</div>
		                    	—
		                    	<div class="mui-numbox" data-numbox-step='1' data-numbox-min='0' data-numbox-max='999'>
		                    	    <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
		                    	    <input class="mui-input-numbox" type="number" id="bTotalPrice" />
		                    	    <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
		                    	</div>
		                    	万
		                    </div>
		                </a>
		            </li>
		            <li class="mui-table-view-cell">
		                <a class="">
		                     房龄
		                    <div class="" align="center">
		                    	<!--<em id="houseAge">不限</em>-->
		                    	<div class="mui-numbox" data-numbox-step='1' data-numbox-min='0' data-numbox-max='999'>
		                    	    <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
		                    	    <input class="mui-input-numbox" type="number" id="aHouseYear" />
		                    	    <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
		                    	</div>
		                    	—
		                    	<div class="mui-numbox" data-numbox-step='1' data-numbox-min='0' data-numbox-max='999'>
		                    	    <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
		                    	    <input class="mui-input-numbox" type="number" id="bHouseYear" />
		                    	    <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
		                    	</div>
		                    	年
		                    </div>
		                </a>
		            </li>
		        </ul>
		        
		        <div class="mui-row mt10 p10">
			            <button type="submit" class="mui-btn mui-btn-block newbgRed colorWhite borderRadius6" id="submitBtn">添加订阅</button>
			    </div>
		</div>
		<script src="js/mui.picker.min.js"></script>
		<script src="js/data.js"></script>
		<script src="js/md5.js"></script>
		<script src="js/enum.util.js"></script>
		<script src="js/generalUtil.js"></script>
		<script src="js/fj_base_data.js"></script>
		<script src="js/network.js"></script>
		<script src="js/fj_area_util.js"></script>
		<script>
			mui('.mui-scroll-wrapper').scroll({
			deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
		});
		
		var city,cityIdentId;	//城市，城市identId
		var cityArea,cityAreaIdentId=0;	//区域，区域identId
		var bedRoomNumber=1,bedRoomName='1室';		//卧室数——类型
		var houseTypeEnumValue=1,houseTypeName='普通住宅';	//房屋类型枚举
		var decorationTypeEnumValue=1,decorationTypeName='精装修';	//装修类型枚举
		var aSquare,bSquare;	//起始匹配面积，结束匹配面积
		var aTotalPrice,bTotalPrice;	//起始匹配售价，结束匹配售价
		var aHouseYear,bHouseYear;		//起始匹配房龄，结束匹配房龄
		
		/***********城市默认为当前城市*************/
		var currentCity = areaUtils.getCurrentCity();
//		document.querySelector('#cityArea').innerHTML = currentCity.areaName;
		city = currentCity.areaName;
		cityIdentId = currentCity.identId;	/*****初始状态为默认的当前城市id*****/
		
		/***************选择城市列表*****************/
//		document.querySelector('#openCityList').addEventListener('tap',function(){
//			mui.openWindow({
//				url:'fj_cities.html',
//				extras:{
//			      parentId:'fj_subscribe'//自定义扩展参数，可以用来处理页面间传值
//			    }
//			});
//		});
		
		document.addEventListener('getCityName',function(event){
			city = event.detail.cityName;
			cityIdentId = event.detail.cityIdentId;

			document.querySelector('#cityArea').innerHTML = city;
			document.querySelector('#citySiteResult').innerHTML = '不限';
		
		});
		
		/*************选择区域***************/
		document.querySelector('#citySite').addEventListener('tap',function(){
			mui.openWindow({
				url:'fj_child_cities.html',
				id:'fj_child_cities',
				extras:{
					parentId:'fj_subscribe',
					identId:cityIdentId,
					currentCity:'泉州市'
				},
			    waiting:{
			      autoShow:true,//自动显示等待框，默认为true
			      title:'正在加载...'//等待对话框上显示的提示内容
			    }
			})
		});
		document.addEventListener('getchildCity',function(event){
			cityArea = event.detail.cityName;
			cityAreaIdentId = event.detail.cityAreaIdentId;
			document.querySelector('#citySiteResult').innerHTML = cityArea;

		});
		
		/******************选择房型*********************/
		document.querySelector('#showHouseType').innerHTML = houseTypeName;
		document.querySelector('#houseType').addEventListener('tap',function(){
			var houseTypePicker = new mui.PopPicker();
			var houseTypeArr = new Array();
			var getHouseType = enumUtils.getEnumDataByType('houseType');
			for (i in getHouseType) {
				houseTypeArr[i]={
					text:getHouseType[i].name,
					value:getHouseType[i].value
				}
			}
			houseTypePicker.setData(houseTypeArr);
			houseTypePicker.pickers[0].setSelectedValue('fourth', 2000);
			houseTypePicker.show(function(SelectedItem) {
				houseTypeName = SelectedItem[0].text;
				houseTypeEnumValue = SelectedItem[0].value;
				document.querySelector('#showHouseType').innerHTML = houseTypeName;
			});
		});
		/******************选择房间类型——卧室数*********************/
		document.querySelector('#showInHouseType').innerHTML = bedRoomName;
		document.querySelector('#inHouseType').addEventListener('tap',function(){
			var bedRoomPicker = new mui.PopPicker();
			
			bedRoomPicker.setData([{
				text:'1室',
				value:1
			},{
				text:'2室',
				value:2
			},{
				text:'3室',
				value:3
			},{
				text:'4室',
				value:4
			},{
				text:'5室及以上',
				value:5
			}]);
			bedRoomPicker.pickers[0].setSelectedValue('fourth', 2000);
			bedRoomPicker.show(function(SelectedItem) {
				bedRoomName = SelectedItem[0].text;
				bedRoomNumber = SelectedItem[0].value;
				document.querySelector('#showInHouseType').innerHTML = bedRoomName;
			});
		});
		
		/********************选择装修类型************************/
		document.querySelector('#showDecorateType').innerHTML = decorationTypeName;
		document.querySelector('#decorateType').addEventListener('tap',function(){
			var decorationTypePicker = new mui.PopPicker();
			var decorationTypeArr = new Array();
			var getDecorationType = enumUtils.getEnumDataByType('decorationType');
			for (i in getDecorationType) {
				decorationTypeArr[i]={
					text:getDecorationType[i].name,
					value:getDecorationType[i].value
				}
//				console.log(getDecorationType[i].value);
			}
			decorationTypePicker.setData(decorationTypeArr);
			decorationTypePicker.pickers[0].setSelectedValue('fourth', 2000);
			decorationTypePicker.show(function(SelectedItem) {
				decorationTypeName = SelectedItem[0].text;
				decorationTypeEnumValue = SelectedItem[0].value;
				document.querySelector('#showDecorateType').innerHTML = decorationTypeName;
			});
		});
		
		document.querySelector('#submitBtn').addEventListener('tap',function(){
			aSquare = document.querySelector('#aSquare').value;
			bSquare = document.querySelector('#bSquare').value;
			
			aTotalPrice = document.querySelector('#aTotalPrice').value;
			bTotalPrice = document.querySelector('#bTotalPrice').value;
			
			aHouseYear = document.querySelector('#aHouseYear').value;
			bHouseYear = document.querySelector('#bHouseYear').value;


			var userInfo = common.myStorage.getItem('userInfo');
			var subscriptionParam = [{
				key:'clientId',
				value:userInfo.clientId
			},{
				key:'city',
				value:city
			},{
				key:'cityIdentId',
				value:cityIdentId
			},{
				key:'area',
				value:cityArea
			},{
				key:'areaIdentId',
				value:cityAreaIdentId
			},{
				key:'bedRoomNumber',
				value:bedRoomNumber
			},{
				key:'houseTypeEnumValue',
				value:houseTypeEnumValue
			},{
				key:'houseTypeName',
				value:houseTypeName
			},{
				key:'decorationTypeEnumValue',
				value:decorationTypeEnumValue
			},{
				key:'decorationTypeName',
				value:decorationTypeName
			},{
				key:'beginSquare',
				value:aSquare
			},{
				key:'endSquare',
				value:bSquare
			},{
				key:'beginTotalPrice',
				value:aTotalPrice
			},{
				key:'endTotalPrice',
				value:bTotalPrice
			},{
				key:'beginHouseYear',
				value:aHouseYear
			},{
				key:'endHouseYear',
				value:bHouseYear
			}];
			fjNetwork.post('fjzx/client/subscription-house.json',subscriptionParam,function(data){
				//成功 
//				console.log(JSON.stringify(data));
				mui.toast(data.msg);
				
				mui.back();
			},function(msg){
				//失败
				mui.toast(msg);
			});
			
		});
		</script>
		
		<script src="js/fj_public_js.js"></script>
	</body>
</html>
